package com.yingdong.logic.http;

import java.util.HashMap;
import java.util.Map;

import com.google.gson.Gson;
import com.yingdong.logic.service.OnlineService;
import com.yingdong.sceneserver.inner.service.HttpHandler;
import com.yingdong.sceneserver.opcode.Dispatcher;
import com.yingdong.utils.HttpUtils;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpRequest;

public class HttpPlayerNumHandler extends HttpHandler {

	@Override
	public void httpHandle(ChannelHandlerContext ctx, HttpRequest request) throws Exception {
		Gson gson = new Gson();
		Map<String, String> out = new HashMap<>();
		out.put("playerNum", OnlineService.getOnlineNum() + "");
		out.put("sessionNum", Dispatcher.sessionMap.size() + "");
		ctx.writeAndFlush(HttpUtils.getResponse(request, gson.toJson(out)));
	}

}
